-
Notifications
You must be signed in to change notification settings - Fork 142
fix: checkUserPushPermission push failure on name #1110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1110 +/- ##
==========================================
- Coverage 77.40% 75.33% -2.07%
==========================================
Files 56 58 +2
Lines 2288 2368 +80
Branches 258 271 +13
==========================================
+ Hits 1771 1784 +13
- Misses 487 554 +67
Partials 30 30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again I think this PR is a partial solution to the issues addressed in #1043 - it'll resolve a problem in the proxy but not the API or UI. I think it also needs to be adjusted to use repo URLs that include .git (as per comments on #1109) - #1043 validates its presence in the UI form, but should perhaps also do so through the API... That said I'm ntt enitrely sure if its required in the git protocol or just a convention.
The tests for the DB client code (which mock the underlying mongo/neDB libs) are worth having as they test smaller units. I'd prefer to have those going in on top of #1043 (as I've been maintaining it it for quite a while).
I agree that the DB tests could be/should be refactored to not carry over state - worse the cypress tests rely on state from the mocha tests which also needed fixing.
Co-authored-by: Juan Escalada <[email protected]> Signed-off-by: Andy Pols <[email protected]>
Co-authored-by: Juan Escalada <[email protected]> Signed-off-by: Andy Pols <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just missing the recent changes from #1109. 🚀
Summary
This PR builds on #1109 to address a bug in
checkUserPushPermission
. The bug caused permission checks to fail when the repository could not be found by name. It also incorrectly assumed that repository names are globally unique, which prevented users from forking the same repository into different projects/organisations within the same git-proxy platform.This fix is split into a separate PR to keep the scope focused and to unblock the security team, who are currently running penetration tests using GitLab.
Fix
This PR:
getRepoByUrl
method (introduced in fix: checkRepoInAuthorisedList push failure on URL mismatch #1109) to simplify logic and reliably load the correct repository.getRepoByUrl
tests accordingly.Notes
A potential future improvement would be to load the repository at the start of the action chain and pass it through to each step, avoiding repeated lookups.
The
isUserPushAllowed
function is no longer used in the main code path, but cannot yet be removed because its tests intestDb.test
implicitly set up state that other tests depend on. Specifically, each test intestDb.test
writes to a file-based database, and subsequent tests rely on that data — making them fragile due to implicit ordering. Removing this function breaks unrelated tests. Refactoring these tests to be isolated and self-contained would be required before safely removingisUserPushAllowed
, but that is out of scope for this PR.